import axios from "axios";
// 创建axios实例
const request=axios.create({
    baseURL:"http://localhost:9091",
    timeout:5000
})
// 添加请求拦截
request.interceptors.request.use(function(config){
    //添加token
    config.headers.Authorization = localStorage.getItem("token");
    return config;
})

// 创建用户axios实例
const requestUserAPI=axios.create({
    baseURL:"http://localhost:9020",
    timeout:5000
})

// 创建站点axios实例
const requestStationAPI=axios.create({
    baseURL:"http://localhost:9040",
    timeout:5000
})
// 添加请求拦截
requestStationAPI.interceptors.request.use(function(config){
    //添加token
    config.headers.Authorization = +localStorage.getItem("token");
    return config;
})

// market
const requestMarketAPI=axios.create({
    baseURL:"http://localhost:9031",
    timeout:5000
})
// market 添加请求拦截
requestMarketAPI.interceptors.request.use(function(config){
    //添加token
    config.headers.Authorization = +localStorage.getItem("token");
    return config;
})

// carManager
const requestCarManager=axios.create({
    baseURL:"http://localhost:8098",
    timeout:5000
})
// carManager 添加请求拦截
requestMarketAPI.interceptors.request.use(function(config){
    //添加token
    config.headers.Authorization = +localStorage.getItem("token");
    return config;
})

// Exception
const requestException=axios.create({
    baseURL:"http://localhost:8088",
    timeout:5000
})
// carManager 添加请求拦截
requestException.interceptors.request.use(function(config){
    //添加token
    config.headers.Authorization = +localStorage.getItem("token");
    return config;
})

export { requestStationAPI };
export { requestUserAPI };
export {requestMarketAPI };
export {requestCarManager };
export {requestException };
export default request;